package njClass.mvc.core
{
	import flash.events.EventDispatcher;

	public class Mediator extends EventDispatcher
	{
		private static var MediatorsArray:Array=new Array();
		private var Name:String;
		private var EventList:Array=new Array();
		private var app:facade=facade.getInstance();
		
		public function Mediator(_Name:String="",_Mediator:Mediator=null)
		{
			Name=_Name;
			MediatorsArray.push({"NAME":Name,"MEDIATOR":_Mediator});
		}
		
		public static function getMediatorByName(string:String):Mediator{
			for(var i:* in MediatorsArray){
				if(MediatorsArray[i]["NAME"]==string){
					return MediatorsArray[i]["MEDIATOR"];
				}
			}
			return null;
		}
		
		public function sendEvent(EventName:String,Target:Object=null):void{
			app.sendEvent(EventName,Target);
		}
		
		public function initEvent(EventName:String,CommandName:Command,Target:Object=null):void{
			app.initEvent(EventName,CommandName,Target);
		}
	}
}